package com.icss.controller;

import com.icss.entity.User;
import com.icss.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.PostConstruct;
import java.util.Arrays;
import java.util.List;

@Controller
@Component
public class UserController {
    @Autowired
    private UserService US;
//    private static UserController UserController;
//
//    //重点三：初始化
//    @PostConstruct
//    public void init() {
//        UserController= this;
//        UserController.US= this.US;
//    }
    @RequestMapping("userList")
    public String selectAll(ModelMap map){
        List<User> users = US.selectAllUser();

        map.addAttribute("users",users);
        return "userList";
    }


}
